<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.io.*"%>
<%@ page import="requestInterFace.Handle.userHandle"%>
<%@ page import="xml.response.*"%>
<%@ page import="xml.root"%>
<%@ page import="util.print.printLogCat"%>
<%@ page import="org.sql.table.*"%>
<%@ page import="xml.var"%>
<%@ page import="java.util.Vector"%>
<%@ page import="java.util.Enumeration"%>
<%@ page import="requestInterFace.UserInfoInterFace.*"%>
<%@ page import="jqgrid.jqgrid"%>
<%@ page import="org.util.getNewData"%>
<%@ page import="util.check"%>
<%@ include file="../../util/paramPrint.jsp" %>
<%@ page trimDirectiveWhitespaces="true" %> 
<%
String User_ID = request.getParameter("User_ID");
String name = request.getParameter("User_Name");
String Login_Pwd = request.getParameter("User_Pwd");
String User_type = request.getParameter("User_Type");
String Login_Name = request.getParameter("Login_Name");//刚上联系人名称
String UP_ID =request.getParameter("UP_ID");//业务员ID
String Addr = request.getParameter("Addr");
String Tel = request.getParameter("Tel");
String userType=(String)session.getAttribute("User_Type");
root root=new root();
if(userType==null||!userType.equals("1")){
root.setStatus("false");
root.setMsg("权限不够");
PrintWriter pw = response.getWriter();
pw.println(root.getXmlString());
pw.flush();
return ;
}
		
		userinfo1_1 user=new userinfo1_1();
		userHandle u=new userHandle();
		if(u.isHaveUser(User_ID)){
		root.setStatus("false");
		root.setMsg("用户ID已存在");
		PrintWriter pw = response.getWriter();
		pw.println(root.getXmlString());
		pw.flush();
		return ;
		}
		
		if(User_ID==null||Login_Pwd==null||User_ID.equals("")||Login_Pwd.equals("")){
		root.setStatus("false");
		root.setMsg("请填写正确用户ID与密码");
		PrintWriter pw = response.getWriter();
		pw.println(root.getXmlString());
		pw.flush();
		return ;
		}
		
		if(Addr==null||Tel==null||Addr.equals("")||Tel.equals("")){
		root.setStatus("false");
		root.setMsg("请输入地址和手机号码");
		PrintWriter pw = response.getWriter();
		pw.println(root.getXmlString());
		pw.flush();
		return ;
		}
		
		if(Login_Pwd!=null&&(!Login_Pwd.equals(""))){
		 user.setInsertField("Login_Pwd", Login_Pwd);
		}
		
		if(User_ID!=null&&(!User_ID.equals(""))){
		 user.setInsertField("User_ID", User_ID);
		}
		if(name!=null&&(!name.equals(""))){
		 user.setInsertField("User_Name", name);
		}
		if(Addr!=null&&(!Addr.equals(""))){
		 user.setInsertField("Addr",Addr);
		}
		if(Tel!=null&&(!Tel.equals(""))){
		 user.setInsertField("Tel", Tel);
		}
		
		if(check.checkString(Login_Name)){
				user.setInsertField("Login_Name", Login_Name);
		}
		
		if(User_type!=null&&!User_type.equals("")){
		if(User_type.equals("3")){//如果要添加客户，需要确认对应业务员是否存在
		if(UP_ID==null||!u.isHaveUP(UP_ID)){
		root.setStatus("false");
		root.setMsg("客户对应业务员不存在");
		PrintWriter pw = response.getWriter();
		pw.println(root.getXmlString());
		pw.flush();
		return ;
		}
		}
		 user.setInsertField("User_type",User_type);
		}
		if(UP_ID!=null&&(!UP_ID.equals(""))){
		 user.setInsertField("UP_ID",UP_ID);
		}
		user.setInsertField("Called_Time",getNewData.GetNowDateAndTime1());
		int row=user.insert();
		root.setRecords(""+row);//设置当前查询到的记录数
		if(row>0){
			root.setStatus("true");
			root.setMsg("添加成功");
		}else{
			root.setStatus("false");
			root.setMsg("用户失败");
		
		}
		//printLogCat.printlnWriter(root.getXmlString());
		String rep=root.getXmlString();
%>
<%=rep%>
